<?php

namespace app\common\model;
use think\Session;
use think\Model;

class Admin extends Model
{
    public function getAdmin($data)
    {
        $admin = Admin::getByName($data['username']);
        if ($admin)
        {
            if ($admin['password']==md5($data['password']))
            {
                Session::set('name',$data['username']);
                Session::set('id',$admin['id']);
                return $res = ['valid'=>1,'message'=>'登陆成功'];
            }else
            {
                return $res = ['valid'=>2,'message'=>'密码错误'];
            }
        }else
        {
            return $res = ['valid'=>3,'message'=>'用户名不存在'];
        }
    }
}
